﻿namespace FiftyOne.Foundation.Mobile.Detection.Wurfl.Handlers
{
    using FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers;
    using FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers.EditDistance;
    using System;

    internal class CatchAllHandler : ReducedInitialStringHandler
    {
        private const int CONFIDENCE = 1;

        protected internal override bool CanHandle(string userAgent)
        {
            return true;
        }

        protected internal override FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers.Results Match(string userAgent)
        {
            bool flag = false;
            FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers.Results results = base.Match(userAgent);
            if ((results == null) || (results.Count == 0))
            {
                results = FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers.EditDistance.Matcher.Match(userAgent, this);
            }
            if (results.GetType() == typeof(FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers.Results))
            {
                flag = true;
            }
            FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers.Results results2 = new FiftyOne.Foundation.Mobile.Detection.Wurfl.Matchers.Results();
            foreach (Result result in results)
            {
                if (result.Device.IsMobileDevice == flag)
                {
                    results2.Add(result.Device);
                }
            }
            return results2;
        }

        internal override byte Confidence
        {
            get
            {
                return 1;
            }
        }
    }
}

